#pragma once

#include "ColligereDatabaseInterfaceBase.hpp"

#include "ColligereAudioDatabaseLayout.hpp"
#include "ColligereAudioDatabaseHandler.hpp"

#include "ColligereIds.hpp"

namespace col 
{

class AudioDatabaseInterface : public DatabaseInterfaceBase
{
public:
	AudioDatabaseInterface();
	virtual ~AudioDatabaseInterface();
	
	void Open ( const wxString &rDbPath, wxAuiManager &rParentLayout );
	void Save ( const wxString &rNewDbPath = wxString() );
	bool Close();
	bool IsOpened() const;

	AudioDatabaseLayout *GetLayout();
	AudioDatabaseHandler *GetHandler();
	const AudioDatabaseLayout *GetLayout() const;
	const AudioDatabaseHandler *GetHandler() const;

	const wxString GetStatusText ( wxUint32 statBarColumn ) const;
	const wxString GetTitleText() const;

	wxUint32 GetId() const;

	void Import ( const wxString &rFile );

	DatabaseProperties GetProperties();

	void DispatchGuiEvent ( wxUint32 eventId );
private:
	void UpdateItem();
	void AddItem();
	void TrashItem();
	void PermRemoveItem();
	void CopyItem();
	void PasteItem();

	struct ImporterId
	{
		enum
		{
			Catraxx = ID_Menu_ImportCatraxxXml,
			OrangeCd = ID_Menu_ImportOrangeCdXml,
			Colligere = ID_Menu_ImportColligereXml,
			Discogs = ID_Menu_ImportDiscogs
		};
	};

	void Import ( wxUint32 importerId, const wxString &rInFile = empty_string );

	struct ExporterId
	{
		enum
		{
			Xml = ID_Menu_ExportToXml
		};
	};

	void Export ( wxUint32 exporterId );

	AudioDatabaseLayout *mpDbLayout;
	AudioDatabaseHandler mDbHandler;

	wxAuiManager *mpParentLayout;

	//! The currently copied item (if any).
	DatabaseItemBasePtr mCurCopied;
};

}